﻿using Furion.DatabaseAccessor;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System.Data;

namespace XinGuanERP.Models.Po.system
{
    public class User : PrivateCommonEntity<string>, IEntityTypeBuilder<User>
    {
        public string? UserName { get; set; }
        public string? RealName { get; set; }
        public string? Avatar { get; set; }
        public string? Desc { get; set; }
        public string? PassWord { get; set; }
        public string? HomePath { get; set; }
        public Role? Role { get; set; }
        public string? RoleId { get; set; }
        public string? Email { get; set; }
        public string? DeptId { get; set; }

        public void Configure(EntityTypeBuilder<User> entityBuilder, DbContext dbContext, Type dbContextLocator)
        {
            entityBuilder.ToTable("BASE_USER");
            entityBuilder.HasKey(t => t.Id);
            entityBuilder.Property(t => t.Id).HasColumnName("USERID");
            entityBuilder.Property(t => t.UserName).HasColumnName("USERNAME");
            entityBuilder.Property(t => t.RealName).HasColumnName("REALNAME");
            entityBuilder.Property(t => t.Avatar).HasColumnName("AVATAR");
            entityBuilder.Property(t => t.Desc).HasColumnName("DESC");
            entityBuilder.Property(t => t.PassWord).HasColumnName("PASSWORD");
            entityBuilder.Property(t => t.HomePath).HasColumnName("HOMEPATH");
            entityBuilder.Property(t => t.CreateUserId).HasColumnName("CREATEUSERID");
            entityBuilder.Property(t => t.CreateUserName).HasColumnName("CREATEUSERNAME");
            entityBuilder.Property(t => t.UpdateUserId).HasColumnName("UPDATEUSERID");
            entityBuilder.Property(t => t.UpdateUserName).HasColumnName("UPDATEUSERNAME");
            entityBuilder.Property(t => t.CreateTime).HasColumnName("CREATETIME");
            entityBuilder.Property(t => t.UpdateTime).HasColumnName("UPDATETIME");
            entityBuilder.Property(t => t.Email).HasColumnName("EMAIL");
            entityBuilder.Property(t => t.RoleId).HasColumnName("ROLEID");
            entityBuilder.Property(t => t.DeptId).HasColumnName("DEPTID");
            entityBuilder.HasOne(u => u.Role).WithMany();
        }
    }
}
